import api from '@/util/request'
import config from '@/settings'

// 老财务共享的供应商查询
export function supplierList(params) {
  return api.get(`${config.oldFssc}/cst/fuzzy-supplier-customer`, { params })
}

export const typeMap = {
  'sap_supplier': 'SAP供应商',
  'sap_customer': 'SAP客户',
  'kingdee_supplier': '金蝶供应商',
  'kingdee_customer': '金蝶客户',
}

// 仅选择名称
export function remoteSupplierList(label) {
  return new Promise((resolve, reject) => {
    supplierList({ nameOrCode: label, size: 50 }).then((data) => {
      data = data.map((item) => {
        return {
          value: item.label,
          label: item.label,
          type: item.type,
          code: item.value,
          name: item.label,
        }
      })
      resolve(data)
    }).catch(reject)
  })
  return
}

// 业态（主体）列表
export function busunessTypeList() {
  return Promise.resolve([
    { value: 'BH', label: '百货' },
    { value: 'DQ', label: '电器' },
    { value: 'CS', label: '超市' },
    { value: 'QM', label: '汽贸' },
    { value: 'ZT', label: '中天' },
    { value: 'SY', label: '仕益' },
    { value: 'LB', label: '劳保' },
    { value: 'BL', label: '保理' },
    { value: 'WL', label: '物流' },
    { value: 'DS', label: '电商' },
    { value: 'ZB', label: '总部' },
  ])
}
